// 所有网络请求
import axios from "./axios"
export default {
  // ************************************ GET ************************************
  getUserData({ url, page, limit, like, id, coachID, identify }) {
    return axios.sendRequest({
      url: url,
      method: 'get',
      params: {
        _page: page,
        _limit: limit,
        name_like: like,
        id: coachID,
        identify: identify,
        coachID: id
      }
    })
  },
  // 获取角色信息
  getRoles() {
    return axios.sendRequest({
      url: '/role',
      method: 'get'
    })
  },
  // 获取权限信息
  getRights() {
    return axios.sendRequest({
      url: "/authority",
      method: 'get'
    })
  },
  // 根据角色信息获取权限信息
  getRightsByRoleInfo(authNameEN) {
    return axios.sendRequest({
      url: "/role",
      method: 'get',
      params: {
        authNameEN: authNameEN
      }
    })
  },
  // 验证登录账号
  verifyLogin({username, password, rolename}) {
    return axios.sendRequest({
      url: '/login',
      method: 'get',
      params: {
        username,
        password,
        rolename
      }
    })
  },
  // 获取账户信息
  getUser({ page, limit, like }) {
    return axios.sendRequest({
      url: "/login",
      method: 'get',
      params: {
        _page: page,
        _limit: limit,
        username_like: like,
      }
    })
  },
  // 获取车辆信息
  getCar({ page, limit, like, isUse }) {
    return axios.sendRequest({
      url: "/cars",
      method: 'get',
      params: {
        _page: page,
        _limit: limit,
        carNumber_like: like,
        isUse: isUse
      }
    })
  },
  // 根据车辆编号获取教练
  getCoachInfoByReverseCar(carNumber) {
    return axios.sendRequest({
      url: "/coach",
      method:'get',
      params: {
        reverseCar_like: carNumber
      }
    })
  },
  // ************************************ POST ************************************
  addUserData(url, UserObj) {
    return axios.sendRequest({
      url: url,
      method: 'post',
      data: UserObj
    })
  },
  // ************************************ PUT ************************************
  updateUserData(url, id, UserObj) {
    return axios.sendRequest({
      url: url + `/${id}`,
      method: 'put',
      data: UserObj
    })
  },
  // ************************************ DELETE ************************************
  deleteUserData(url, id) {
    return axios.sendRequest({
      url: url + `/${id}`,
      method: 'delete',
    })
  },
}